<template>
	<view class="background">
		<u-modal v-model="removeShow" content="确定解除绑定该账号?" show-cancel-button @confirm="getrelieveBindParentQid"></u-modal>
		<u-toast ref="uToast" />
		<view class="vue-content">
			<view class="picture box box-align-center box-pack-between">
				<text class="span">账号头像</text>
				<view class="picture_img">
					<img :src="infoForm.avatar ? infoForm.avatar : 'https://jiaoguanyi008.oss-cn-shenzhen.aliyuncs.com/miniPro/images/imgs/leftIcon/addSn.png'"
					 alt />
				</view>
			</view>
			<u-form :model="infoForm" ref="uForm">
				<view class="" style="background-color: #FFFFFF;margin-top: 20rpx;">
					<u-form-item prop="name" label="名称" label-width="180" :label-style="{'padding-left': '20rpx'}" :border-bottom="false">
						<u-input placeholder="未设置" input-align="right" :custom-style="{'padding-right': '20rpx'}" v-model="infoForm.name" :disabled="true"/>
					</u-form-item>
					<u-form-item prop="qid" label="账号" label-width="180" :label-style="{'padding-left': '20rpx'}" :border-bottom="false">
						<u-input placeholder="未设置" input-align="right" :custom-style="{'padding-right': '20rpx'}" v-model="infoForm.qid"
						 :disabled="true" />
					</u-form-item>
				</view>
			</u-form>
			<view class="vue-input remove_border">
				<view class="vue-button ">
					<button size="large" @click="removeShow = true">解除绑定</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { relieveBindParentQid } from '../../api/myEquipment';
	export default {
		data() {
			return {
				removeShow: false, //解绑模拟框
				infoForm: {
					userId: uni.getStorageSync('userId'),
					lastIp: uni.getStorageSync('Ip'),
					name: '',
					avatar: '',
					qid: ''
				},
			}
		},
		
		onLoad(option) {
			const item = JSON.parse(decodeURIComponent(option.item));
			if (item) {
				this.infoForm.avatar = item.avatar
				this.infoForm.qid = item.content
				this.infoForm.name = item.name
			}
		},
		methods: {
			getrelieveBindParentQid() {
				relieveBindParentQid({
					userId: uni.getStorageSync("userId"),
					qid: this.infoForm.qid
				}).then(res => {
					this.$refs.uToast.show({
						title: res.msg,
						icon: false,
						type: 'success',
					})
					setTimeout(() => {
					    let pages = getCurrentPages(); //获取所有页面栈实例列表
					    let prevPage = pages[pages.length - 2]; //上一页页面实例
					    uni.navigateBack({ //uni.navigateTo跳转的返回，默认1为返回上一级
					      delta: 1,
					      success:(event)=>{
					        prevPage.$vm.getParentQidControl();  // getData 是自己对应的方法名
					      }
					    });
					  }, 500)
				}).catch(err =>{})
			}
		}
	}
</script>

<style>
	page {
		background-color: #FFFFFF;
	}
</style>

<style scoped lang="scss">
	.header {
		height: 50px;
		margin-top: 29px;
		border-radius: 8px;
		margin: 27px 13px auto;
		overflow: hidden;

		.vue-return img {
			height: 30px;
			width: 25px;
			margin-top: 9px;
			display: inline;
			float: left;
		}

		h2 {
			float: left;
			font-size: 16px;
			margin: 12px 20px auto;
			letter-spacing: 1px;
		}
	}

	.vue-content {
		height: 100%;
		margin: 10px 10px 10px 10px;
		overflow: hidden;

		.picture {
			background-color: #fff;
			display: flex;
			padding: 10px;
			justify-content: space-between;
			align-items: center;

			.span {
				font-size: 28rpx;
				line-height: 60px;
				color: #212121;
			}

			.picture_img {
				height: 80px;
				width: 80px;
				border-radius: 50%;
				overflow: hidden;

				image {
					width: 100%;
					height: 100%;
				}
			}
		}

		.vue-input {
			height: 60px;
			padding: 0 10px;
			border-bottom: solid 1px #e1e6ed;
			box-sizing: border-box;

			.span {
				font-size: 16px;
				line-height: 60px;
				color: #212121;
			}

			.vue-input-right {
				float: right;

				label {
					color: #5d5d5d;
					font-size: 14px;
					margin-top: 16px;
					float: right;
					width: 130px;
				}

				/deep/.input {
					color: #5d5d5d;
					float: right;
					width: 130px;
					overflow: hidden;
					font-size: 14px;
					margin-top: 18.5px;
				}

				/deep/ .vue-input-right {
					margin-left: 6px;
				}

				a {
					line-height: 60px;
					letter-spacing: 2px;
					font-size: 16px;
					color: red;
				}

				.span {
					float: right;
					width: 130px;
					overflow: hidden;
					font-size: 16px;
				}

				img {
					height: 17px;
					width: 10px;
					margin-top: 20px;
					margin-right: 10px;
				}

				/deep/.van-popup--top {
					width: 93%;
					// margin: 0 auto;
					// margin-left: 13.6px;
					position: absolute;
					left: 13.6px;
				}

				/deep/.van-cell__title {
					text-align: center;
				}

				/deep/ .van-dropdown-item__option--active {
					text-align: center;
				}

				/deep/.van-dropdown-menu .van-hairline--top-bottom {
					border: none;
				}

				/deep/ .van-ellipsis {
					font-size: 16px;
					color: #797979;
					line-height: normal;
					letter-spacing: 1px;
				}

				/deep/.van-overlay {
					background-color: #f4f4f4;
				}

				/deep/.van-dropdown-menu__title::after {
					border: none;
				}

				/deep/ .van-hairline--top-bottom::after {
					border-width: 0px;
				}

				.name {
					font-size: 16px;
					color: #888888;
				}
			}
		}
	}

	.button {
		background-color: #ffffff;
		border: 1px solid #ffffff;
		border-radius: 8px;
		width: 90%;
		float: left;
		left: 5%;
		letter-spacing: 10px;
		font-weight: 600;
		font-size: 18px;
	}

	.vue-button {
		position: absolute;
		bottom: 30px;
		width: 90%;
		float: left;
		left: 5%;

		button {
			border-radius: $uni-border-radius-lg;
			background-color: #4880ff;
			color: #FFFFFF;
			overflow: hidden;
		}
	}

	.relieve_button {
		bottom: 60px !important;
	}

	/deep/ button[type="primary"] {
		background-color: #fff;
		letter-spacing: 6px;
		color: #5e5e5e;
	}

	.remove_border {
		border: none !important;
	}

	.info-user {
		margin: 10px 0;
		background-color: #fff;
		border-radius: 6px;
	}
	.invite{
		margin-top: 40rpx;
		padding: 0 20rpx;
		text {
			font-size: 28rpx;
			color: #333333;
		}
	}
</style>
